package com.xcy.quickhand.controller;

import com.github.pagehelper.PageInfo;
import com.xcy.quickhand.model.Video;
import com.xcy.quickhand.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2023/2/11 21:19
 */
@RestController
@RequestMapping("video")
public class VideoController {

    @Autowired
    VideoService videoService;

    @RequestMapping("saveVideo")
    public String saveVideo(String cookie, String userId) {
        Integer i = videoService.saveVideo(cookie, userId);
        return "";
    }

    @RequestMapping("selectAll")
    public List<Video> selectAll() {
        return videoService.selectList();
    }

    @GetMapping
    public PageInfo selectPageList(Integer page, Integer pageSize){
        return videoService.selectByPage(page, pageSize);
    }

    /**
     * 保存作者id（3x34qvqz6n7ndsu）
     * @param cookie
     * @return
     */
    @RequestMapping("saveAuthor")
    public String saveAuthor(String cookie) {
        Integer i = videoService.saveAuthor(cookie);
        return "";
    }

}
